/**
 * @author Khoa Nguyen
 * @email: nguyentrananh_khoa@yahoo.com
 */
(function ( $ ){
	$.fn.ajaxnify = function( options ) {		
		var defaults = {
			url: false,
			event: 'click',			
			type: 'post',
			dataType: 'html',
			eleOutput: 'body',
			eleEventOn: false
	    };
		
		var settings = $.extend( {}, defaults, options );				
			
		$(document).on(settings.event,settings.eleEventOn,function(e){
			e.preventDefault();
			e.stopPropagation();
			$.ajax({
		        url         :   settings.url !== false ? settings.url : $(this).attr('href') ,
		        type        :   settings.type,
		        async       :   true,
		        cache       :   false,
		        dataType    :   settings.dataType
		        
		    }).done(function(response){
		    	$(settings.eleOutput).html(response);
		    }).fail(function(jqXHR, textStatus){    	
		    	alert( "Request failed: " + textStatus );
		    });   
		});				
	}
}( jQuery ));

 /* Calling ajax for pagination */
$(document).ready(function() {	
	$.fn.ajaxnify({	
		eleOutput: '#ajax-content',
		eleEventOn: '.pagination a'
	});
});